import { defineStore } from "pinia";
import { EaseChatClient } from "@/IM/initImSdk";
interface Imstates {
  loginState: boolean;
  networkStatus: boolean;
  userInfo: {
    hxId: string;
    nickname: string;
    avatarurl: string;
  };
}
export const useImStatusStore = defineStore("imstatus", {
  state: (): Imstates => ({
    loginState: false,
    networkStatus: false,
    userInfo: {
      hxId: "",
      nickname: "",
      avatarurl: "",
    },
  }),
  actions: {
    CHANGE_LOGIN_STATUS(state: boolean) {
      this.loginState = state;
    },
    CHANGE_NETWORK_STATUS(state: boolean) {
      this.networkStatus = state;
    },
    SET_USER_INFO(infos: typeof this.userInfo) {
      this.userInfo = Object.assign(this.userInfo, infos);
    },
    /**
     * @description getMyUserInfo - 获取登陆用户属性
     * @param userId - 用户id
     */
    async getMyUserInfo(userId: any) {
      const data = EaseChatClient.fetchUserInfoById(userId);
      console.log(data);
    },
  },
});
